package com.spring.jude.google;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.spring.jude.google.service.GoogleService;

public class GoogleController extends MultiActionController {
	private static final Log logger = LogFactory.getLog(GoogleController.class);
	
	private GoogleService googleService;
	
	public void setGoogleService(GoogleService googleService) {
		this.googleService = googleService;
	}
	
	public ModelAndView maps(HttpServletRequest request,
			HttpServletResponse response) {
		logger.debug(" >> " + this.getClass().getName());
		System.out.println("Maps >> ");
		return new ModelAndView("google/maps");
	}
	
	public ModelAndView saveLocation(HttpServletRequest request,
			HttpServletResponse response) {
		logger.debug(" >> " + this.getClass().getName());
		
		Map requestMap = new HashMap();
		requestMap.put("request", request);
		
		googleService.saveLocation(requestMap);
		return new ModelAndView("");
	}
	
	public ModelAndView loadLocation(HttpServletRequest request,
			HttpServletResponse response) {
		logger.debug(" >> " + this.getClass().getName());
		System.out.println(">> Controller.loadLocation >> ");
		
		Map requestMap = new HashMap();
		requestMap.put("request", request);
		
		googleService.loadLoation(requestMap);
		return new ModelAndView("");
	}
}
